<?php
namespace App\Services;
use Qcloud\Sms\SmsSingleSender;

class Sms 
{
	

	public static function sendMsg($mobile)
    {
    	$appid = '1400238257';
    	$appkey = '8000baff6a2263faf51b23e02323b17d';

    	$code   = mt_rand(1000,9999);
    	RedisService::set('wedding:sms:'.$mobile,$code);

		try {
		    $ssender = new SmsSingleSender($appid, $appkey);
		    $result = $ssender->send(0, "86", $mobile,
		        "【迎亲纪】验证码：{$code}，为了保障您的账户安全，请勿向他人泄漏验证码信息", "", "");
		    $result = json_decode($result,true);
		    if($result['result']==0) {
		    	$rs['status'] = true;
		    	return $rs;
		    } else {
		    	$rs['status'] = false;
		    	$rs['msg']    = $result['errmsg'];
		    	return $rs;
		    }
		    
		} catch(\Exception $e) {
			dd($e->getMessage());
		    return false;
		}
    }
}